<% layout('/layouts/default.html', {title: '销售单管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('销售单管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('st:stSaleBill:edit')){ %>
					<a href="${ctx}/st/stSaleBill/form" class="btn btn-default btnTool" title="${text('新增销售单')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${stSaleBill}" action="${ctx}/st/stSaleBill/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('单据号')}：</label>
					<div class="control-inline">
						<#form:input path="billNo" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('单据日期')}：</label>
					<div class="control-inline">
						<#form:input path="billDate" readonly="true" maxlength="20" class="form-control laydate width-datetime"
							dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('销/退货')}：</label>
					<div class="control-inline width-120">
						<#form:select path="saleOrNot" dictType="st_sale_or_not" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('客户')}：</label>
					<div class="control-inline">
						<#form:input path="customId" maxlength="36" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('销售类型')}：</label>
					<div class="control-inline width-120">
						<#form:select path="saleType" dictType="st_sale_type" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('生产状态')}：</label>
					<div class="control-inline width-120">
						<#form:select path="productStatus" dictType="st_product_status" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('合同编号')}：</label>
					<div class="control-inline">
						<#form:input path="contractNo" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('业务员编码')}：</label>
					<div class="control-inline">
						<#form:input path="bussinessManCode" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('业务员')}：</label>
					<div class="control-inline">
						<#form:input path="businessMan" maxlength="5" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('部门编码')}：</label>
					<div class="control-inline">
						<#form:input path="deptCode" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('部门')}：</label>
					<div class="control-inline">
						<#form:input path="deptName" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('币别')}：</label>
					<div class="control-inline width-120">
						<#form:select path="moneyType" dictType="st_money_type" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('金额')}：</label>
					<div class="control-inline">
						<#form:input path="money" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('收款账期')}：</label>
					<div class="control-inline">
						<#form:input path="receipt" maxlength="36" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('项目归属')}：</label>
					<div class="control-inline">
						<#form:input path="projectBelong" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('地址')}：</label>
					<div class="control-inline">
						<#form:input path="address" maxlength="40" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否做业绩考核')}：</label>
					<div class="control-inline width-120">
						<#form:select path="examine" dictType="st_is_examine" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('交货日期')}：</label>
					<div class="control-inline">
						<#form:input path="deliveryDate" readonly="true" maxlength="20" class="form-control laydate width-datetime"
							dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('备注信息')}：</label>
					<div class="control-inline">
						<#form:input path="remarks" maxlength="500" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
	var allData;
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("单据号")}', name:'billNo', index:'a.bill_no', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/st/stSaleBill/form?id='+row.id+'" class="btnList" data-title="${text("编辑销售单")}">'+(val||row.id)+'</a>';
		}},
		{header:'${text("单据日期")}', name:'billDate', index:'a.bill_date', width:150, align:"center"},
		{header:'${text("销/退货")}', name:'saleOrNot', index:'a.sale_or_not', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('st_sale_or_not')}, val, '${text("未知")}', true);
		}},
		{header:'${text("客户")}', name:'customId', index:'a.custom_id', width:150, align:"left"},
		{header:'${text("销售类型")}', name:'saleType', index:'a.sale_type', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('st_sale_type')}, val, '${text("未知")}', true);
		}},
		{header:'${text("生产状态")}', name:'productStatus', index:'a.product_status', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('st_product_status')}, val, '${text("未知")}', true);
		}},
		{header:'${text("合同编号")}', name:'contractNo', index:'a.contract_no', width:150, align:"left"},
		// {header:'${text("业务员编码")}', name:'bussinessManCode', index:'a.bussiness_man_code', width:150, align:"left"},
		{header:'${text("业务员")}', name:'businessMan', index:'a.business_man', width:150, align:"left"},
		// {header:'${text("部门编码")}', name:'deptCode', index:'a.dept_code', width:150, align:"left"},
		{header:'${text("部门")}', name:'deptName', index:'a.dept_name', width:150, align:"left"},
		{header:'${text("币别")}', name:'moneyType', index:'a.money_type', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('st_money_type')}, val, '${text("未知")}', true);
		}},
		{header:'${text("金额")}', name:'money', index:'a.money', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text("收款账期")}', name:'receipt', index:'a.receipt', width:150, align:"left"},
		{header:'${text("项目归属")}', name:'projectBelong', index:'a.project_belong', width:150, align:"left"},
		{header:'${text("地址")}', name:'address', index:'a.address', width:150, align:"left"},
		{header:'${text("是否做业绩考核")}', name:'examine', index:'a.examine', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('st_is_examine')}, val, '${text("未知")}', true);
		}},
		{header:'${text("交货日期")}', name:'deliveryDate', index:'a.delivery_date', width:150, align:"center"},
		{header:'${text("更新时间")}', name:'updateDate', index:'a.update_date', width:150, align:"center"},
		{header:'${text("备注信息")}', name:'remarks', index:'a.remarks', width:150, align:"left"},
		{header:'${text("操作")}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('st:stSaleBill:edit')){ %>
				actions.push('<a href="${ctx}/st/stSaleBill/form?id='+row.id+'" class="btnList" title="${text("编辑销售单")}"><i class="fa fa-pencil"></i></a>&nbsp;');
				actions.push('<a href="${ctx}/st/stSaleBill/delete?id='+row.id+'" class="btnList" title="${text("删除销售单")}" data-confirm="${text("确认要删除该销售单吗？")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			<% } %>
			return actions.join('');
		}}
	],
	showCheckbox: true,
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		allData=data.list;
	}
});
function getSelectData(){
	var rowIdArr=$('#dataGrid').dataGrid('getSelectRows');
	// console.info("rowID",rowIdArr);
	// var select=$('#dataGrid').dataGrid('getRowData', rowId);
	// select['id']=rowId;
	var select=[];
	for(var index in allData){

		var item=allData[index];
		if(-1 != rowIdArr.indexOf(item.id)){
			select.push(item);
		}
	}
	return select;
}
</script>